<html>
<head><meta charset="utf-8"><title>rust analyzer postfix type completions · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html">rust analyzer postfix type completions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221313326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221313326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221313326">(Dec 31 2020 at 20:09)</a>:</h4>
<p>Hello!</p>



<a name="221313344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221313344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221313344">(Dec 31 2020 at 20:09)</a>:</h4>
<p>Ooops i have press enter to send <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="221313442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221313442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221313442">(Dec 31 2020 at 20:11)</a>:</h4>
<p>Well i just wanted to get thoughts on an idea i had which i think would be great for rust analyzer. One pattern i often have to do is wrap a type in Option, Vec, etc. Therefore i was thinking it would be nice for rust analyzer to be able to complete something like <code>usize.vec</code> to <code>Vec&lt;usize&gt;</code>. Rust analyzer would detect if the type has a generic (and maybe if the type being completed can be put into the generic?) and offer a completion for it. This would only work for types with generics in scope so as to not have too many completions.</p>



<a name="221315179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221315179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221315179">(Dec 31 2020 at 20:46)</a>:</h4>
<p>Hello! rust-analyzer supports a couple of postfix completion, as you might have already noticed, but as a design choice, there aren't a lot of them to avoid polluting the completion results. I think we don't even have <code>Rc</code> and <code>Arc</code> yet. I'm not sure the ones you're proposing are that clear, or useful (I thought <code>foo.vec</code> would expand to <code>vec![foo]</code>, which is a reasonable expectation, although not what you would like). And unfortunately I don't think we can provide postfix replacements like this without going through the completion list.</p>



<a name="221315246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221315246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221315246">(Dec 31 2020 at 20:47)</a>:</h4>
<p>Maybe these could be made configurable, once we support a config file, but I'm personally not a fan of those (because when multiple people work on a project, they might have different ideas about what postfix completions are useful).</p>



<a name="221319141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221319141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221319141">(Dec 31 2020 at 21:50)</a>:</h4>
<p>You're correct in saying that a lot of them pollute the results, however, i don't exactly agree with that in this case. That is because <code>usize.</code> can't quite complete to anything else, or am i missing something? <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="221319173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221319173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221319173">(Dec 31 2020 at 21:50)</a>:</h4>
<p>I think you've misunderstood what i meant, i do not mean <code>5.vec</code> -&gt; <code>vec![5]</code>, i mean in a type, e.g. <code>usize.vec</code> -&gt; <code>Vec&lt;usize&gt;</code></p>



<a name="221319205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221319205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221319205">(Dec 31 2020 at 21:51)</a>:</h4>
<p>I also don't see why you would need a config file versus just making this an editor config</p>



<a name="221341134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221341134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221341134">(Jan 01 2021 at 07:54)</a>:</h4>
<p>Yes, you're right about that, we could decide to complete to <code>Vec&lt;T&gt;</code> or even <code>vec![foo]</code> depending on what's on the left side</p>



<a name="221382543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust%20analyzer%20postfix%20type%20completions/near/221382543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust.20analyzer.20postfix.20type.20completions.html#221382543">(Jan 02 2021 at 03:55)</a>:</h4>
<p>I think RA already distinguishes between type completions and expr completions, no?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>